#include "iexec.h"
#include <stdio.h>
#include <string.h>

void canvassize (double x, double y)
{
   printf ("Set Canvas Size %g, %g.\n", x, y);
}

void reset (void)
{
   printf ("Reset.\n");
}

void clear (void)
{
   printf ("Clear.\n");
}

void hide (void)
{
   printf ("Hide turtle.\n");
}

void canvascolor (double r, double g, double b)
{
   printf ("Set Canvas Color. R,G,B: %g, %g, %g.\n", r, g, b);
}

void pencolor (double r, double g, double b)
{
   printf ("Set Pen Color. R,G,B: %g, %g, %g.\n", r, g, b);
}

void penwidth (double d)
{
   printf ("Set pen width as %g.\n", d);
}

void go (double x, double y)
{
   printf ("Go %g, %g.\n", x, y);
}

void direction (double d)
{
   printf ("Direction %g.\n", d);
}

void turnright (double d)
{
   printf ("Turn Right %g degree.\n", d);
}

void turnleft (double d)
{
   printf ("Turn Left %g degree.\n", d);
}

void forward (double d)
{
   printf ("Forward %g.\n", d);
}

void backward (double d)
{
   printf ("Backward %g.\n", d);
}

void fontsize (double d)
{
   printf ("Set Fontsize as %g.\n", d);
}

void print (char* str)
{
   printf ("PRINT --- %s .\n", str);
}

void penup (void)
{
   printf ("Pen Up.\n");
}

void pendown (void)
{
   printf ("Pen Down.\n");
}

void center (void)
{
   printf ("Move to center.\n");
}

void gox (double d)
{
   printf ("Gox %g.\n", d);
}

void goy (double d)
{
   printf ("Goy %g.\n", d);
}

void wrapon (void)
{
   printf ("Warp on.\n");
}

void wrapoff (void)
{
   printf ("Warp off.\n");
}


void show (void)
{
   printf ("Show turtle.\n");
}

#define BUF_SIZE 256

char* inputwindow(char* str)
{
   static char buf[INPUT_SIZE];
   int len;

   printf ("... Input %s:", str);
   fgets (buf, INPUT_SIZE, stdin);
   len = strlen (buf);

   if (len == 0) {
      return buf;
   }
   if (buf[len-1] == 0x0A || buf[len-1] == 0x0D) {
      buf[len-1] = '\0';
   }
   return buf;
}

void message (char* txt)
{
   printf ("Message: %s\n", txt);
}

void debug (char* txt)
{
   printf ("%s", txt);
}

void error (char* txt)
{
   printf ("%s", txt);
}

i_exec_t g_test_exec = {
   canvassize,
   reset,
   clear,
   hide,
   canvascolor,
   pencolor,
   penwidth,
   go,
   direction,
   turnright,
   turnleft,
   forward,
   backward,
   fontsize,
   print,
   penup,
   pendown,
   center,
   gox,
   goy,
   wrapon,
   wrapoff,
   show,
   inputwindow,
   message,
   debug,
   error
};
